package com.hardy.leecode;

/**
 * Author: Hardy
 * Date:   2020/9/7
 * Description:
 **/
public class Que9 {

    public static void main(String[] args) {

        System.out.println(new Solution());
    }

    static class Solution {

        public boolean isPalindrome(int x) {
            if (x < 0 || (x > 10 && x % 10 == 0)) return false;

            int res = 0;

            for (int n = x; n > 0; n = n / 10) {
                res = res * 10 + n % 10;
            }
            return res == x;
        }

        public boolean isPalindrome1(int x) {
            if (x < 0) return false;
            String s = String.valueOf(x);

            int i = 0;
            int j = s.length() - 1;

            while (true) {
                if (i >= j) return true;
                if (s.charAt(i++) != s.charAt(j--)) return false;
            }
        }


    }
}
